package com.example.design.decorator.coffeeebar.decorator;

import com.example.design.decorator.coffeeebar.component.Drink;

/**
 * @Description 装饰者类
 * @ClassName Decorator
 * @Author Administrator
 * @Date 2020/5/13 18:08
 * @Version 1.0.0
 */
public class Decorator extends Drink {
    //注意这里面有个超类的对象，因为这是个装饰者，
    //所以他包装的是一个单品，或者是一个被包装过的单品.所以他用个超类的类型
    private Drink drink;

    public Decorator(Drink drink) {
        this.drink = drink;
    }

    @Override
    public float cost() {
        return super.getPrice() + drink.cost();
    }

    @Override
    public String getDescription() {
        return drink.getDescription() + " && " + super.description + ": " + super.getPrice();
    }

}
